<style scoped lang="scss">
.brand-panel-main {
  // background: #fff;
}
.brand-panel-main-relative {
  border-radius: R(10px);
  margin: R(27) 0;
  .brand-panel-bom-list:not(:last-child) {
    border-bottom: 1px solid #eee;
  }
  .brand-panel-bom-list {
    font-size: R(30px);
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #000000;
    .brand-icon {
      width: R(50);
      height: R(50);
      margin-right: R(16);
    }
    .right-active-right {
      margin-left: auto;
    }
  }
}
/deep/input {
  height: auto;
}
.a-title {
  padding-left: R(36);
  font-size: R(26);
  color: #666;
  margin-top: R(34);
}
.line{
  height: R(1);
  background: #eee;
}
</style>
<template>
  <div class="brand-panel-main">
    <nav-bar :options="navBarOptions"  />
    <div class="brand">
      <van-search
        v-model="query.agentNo"
        shape="round"
        show-action
        clearable
        placeholder="请输入代理商编号"
      >
        <template #action>
          <div @click="getList" style="color: #83837d">搜索</div>
        </template>
      </van-search>
      <div class="line"></div>
      <!-- <van-field
        readonly
        clickable
        name="picker"
        :value="query.brandName"
        input-align="right"
        right-icon="arrow-down"
        label="品牌"
        placeholder="请选择"
        @click="chooseBrand"
      /> -->
    </div>
    <!-- <van-divider ></van-divider> -->
    <p class="a-title">代理商列表:</p>
    <div class="brand-panel-main-relative">
      <div class="brand-panel-bom" v-if="list.length > 0">
        <div
          class="brand-panel-bom-list flex-align-center"
          v-for="(item, index) in list"
          :key="index"
          @click="toDetail(item)"
        >
          <van-cell
            :title="item.agentName + '(' + item.agentNo + ')'"
            is-link
            :value="item.brandName"
          />
        </div>
      </div>
      <noData tipsText="您暂无直属代理商~!" style="padding-bottom: 20px" v-else></noData>
    </div>
    <!-- <van-popup v-model="brandP" position="bottom">
      <van-picker
        show-toolbar
        title="品牌"
        :columns="brandList"
        @confirm="brandChoose"
        value-key="brandName"
      />
    </van-popup> -->
  </div>
</template>

<script>
import { signInfo } from "_a/traditionalV1/signInfo";
import { listInfo } from "_a/traditionalV1/agentUnderRateList";
export default {
  name: "agentRateSet",
  data() {
    return {
      navBarOptions: {
        backPrevPage: true,
      },
      brandList: [],
      list: [],
      brandP: false,
      query: {},
    };
  },
  created() {
    this.$tip.loading();
    this.getBrandList();
  },
  methods: {
   
    toDetail(item) {
      this.$storage.setStore({
        name: "agentRateSet",
        content: JSON.stringify(item),
      });
      this.$router.push({
        name: "agentRateSet",
      });
    },
    chooseBrand() {
      this.brandP = true;
    },
    brandChoose(item) {
      this.brandP = false;
      this.query.brandCode = item.brandCode;
      this.query.brandName = item.brandName;
      this.getList();
      //   console.log(item);
    },
    getBrandList() {
      signInfo({ pageSize: 999 }).then((res) => {
        this.brandList = res.data;
        // 自己的数据
        this.query.brandCode = this.brandList[0].brandCode;
        this.query.brandName = this.brandList[0].brandName;
        this.$tip.loaded();
        this.getList();
      });
    },
    getList() {
      listInfo(this.query).then((res) => {
        this.list = res.rows;
      });
    },
  },
};
</script>

